package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.DeviceTarget;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.DeviceType;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;


public class GxDeviceTarget extends DeviceTarget {
    public GxDeviceTarget(Element element) {
        NodeList devicesNode = element.getElementsByTagName("DeviceTypeCollection");
        if (devicesNode.getLength() > 0) {
            NodeList deviceTypeNode = ((Element)devicesNode.item(0)).getElementsByTagName("DeviceType");
            DeviceType[] devices = new DeviceType[deviceTypeNode.getLength()];
            for (int temp = 0; temp < deviceTypeNode.getLength(); temp++) {
                if (deviceTypeNode.item(temp).getChildNodes().getLength() > 0) {
                    devices[temp] = DeviceType.fromString(deviceTypeNode.item(temp).getChildNodes().item(0).getNodeValue());
                }
            }
            this.setDevices(devices);
        }
    }
}
